package com.dwjm.shop.Jbp.Merchant;

import com.dwjm.shop.Jbp.Goods.Goods;
import com.dwjm.shop.Jbp.utils.ConnectionDatabaseForSQLSeverUseJdbc;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
//定义类MerchantDaoImpl实现MerchantDao接口
public class MerchantDaoImpl implements MerchantDao {

    Connection connection = null;

    PreparedStatement pstmt = null;
    ResultSet rset = null;

    public MerchantDaoImpl(){
        connection  = ConnectionDatabaseForSQLSeverUseJdbc.getConnection();
    }


    @Override
    public boolean login(String account, String password) {
        try {
               pstmt=connection.prepareStatement("SELECT account FROM t_merchant WHERE account=? AND password=?");
                pstmt.setString(1, account);
                pstmt.setString(2, password);
                rset= pstmt.executeQuery();
                if(rset.next()){
                    return true;
                }
        } catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }



}
